package main

import "fmt"

/*
	设定数组中	为1代表墙壁
				为0代表路未走过
				为2代表路已走过
				为3代表路不通
 */

func getWayToTarget(data *[8][8]int, x int, y int) bool {
	if data[6][6] == 2{
		return true
	}
	if data[x][y] == 0 {
		//代表为走过此地
		//寻路顺序
		data[x][y] = 2

		if getWayToTarget(data, x+1, y) { //下
			return true
		} else if getWayToTarget(data, x, y+1) { //右
			return true
		}else if getWayToTarget(data, x-1, y) {  //上
			return true
		}else if getWayToTarget(data, x, y-1) {  //左
			return true
		}else {
			//走到此处证明该点上下左右都不通，则将其置为3
			data[x][y] = 3
			return false
		}
	}else {
		return false
	}
}

func main() {
	var myMap [8][8]int
	for i,v := range myMap {
		for j,_ := range v {
			if i == 0 || i == 7{
				myMap[i][j] = 1
			}
			if j == 0 || j == 7 {
				myMap[i][j] = 1
			}
		}
	}

	myMap[3][1] = 1
	myMap[3][2] = 1

	getWayToTarget(&myMap, 1, 1)

	for _, j := range myMap {
		fmt.Println(j)
	}
}
